//
//  IssueViewController.m
//  Toyohu
//
//  Created by celia on 16/3/30.
//  Copyright (c) 2016年 celia. All rights reserved.
//

#import "IssueViewController.h"
#import "IssueTableViewCell.h"
static NSString *IssueReuseId = @"IssueTableViewCell";
#define WIDTH self.view.bounds.size.width
#define HEIGHT self.view.bounds.size.height
@interface IssueViewController ()<UITableViewDelegate,UITableViewDataSource>{
    UITableView *myTableView;
    
}

@end

@implementation IssueViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden = NO;
    self.view.backgroundColor = [UIColor colorWithRed:235/255.0 green:235/255.0 blue:241/255.0 alpha:1];
    myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,80,WIDTH,HEIGHT-64) style:UITableViewStylePlain];
    myTableView.delegate = self;
    myTableView.dataSource = self;
    [myTableView registerNib:[UINib nibWithNibName:@"IssueTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:IssueReuseId];
    myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
     self.automaticallyAdjustsScrollViewInsets=NO;
    [self.view addSubview:myTableView];
    myTableView.rowHeight = 138;
    
    
    UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 30)];
    navLabel.textColor = [UIColor whiteColor];
    navLabel.backgroundColor = [UIColor clearColor];
    navLabel.textAlignment = NSTextAlignmentCenter;
    navLabel.text = @"我发布的";
    navLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    self.navigationItem.titleView = navLabel;
    
    //导航栏左边项
    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeSystem];
    leftButton.frame = CGRectMake(0, 0, 10, 15);
    [leftButton setBackgroundImage:[UIImage imageNamed:@"ARROW---LEFT@2x"] forState:UIControlStateNormal];
    [leftButton addTarget:self action:@selector(goBackPreviousPage) forControlEvents:UIControlEventTouchDown];
    
    UIBarButtonItem *leftButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
    self.navigationItem.leftBarButtonItem = leftButtonItem;
    
    
    
    
    UIView *View = [[UIView alloc]initWithFrame:CGRectZero];
    myTableView.tableFooterView= View;
   
}

//返回前一个视图控制器
-(void)goBackPreviousPage{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row==0) {
        IssueTableViewCell*cell = [myTableView dequeueReusableCellWithIdentifier:IssueReuseId ];
        
        if (!cell) {
            cell = (IssueTableViewCell *)[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier: IssueReuseId];
        }
        cell.name.text = @"孩子不打疫苗行不行？";
        cell.content.text = @"对疫苗这块的认知为0，但是我想知道，如果还是从来未打过疫苗，是不是可行的？";
        cell.time.text = @"2016-03-26";
        cell.good.text = @"1463";
        cell.comment.text = @"582";
        cell.love.text = @"1350";
        return cell;
    }
   else if (indexPath.row==1) {
        IssueTableViewCell*cell = [myTableView dequeueReusableCellWithIdentifier:IssueReuseId ];
        if (!cell) {
            cell = (IssueTableViewCell *)[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier: IssueReuseId];
        }
        cell.name.text = @"幼儿注射非冷藏疫苗有什么危害？";
        cell.content.text = @"本次山东非冷藏疫苗涉及的儿童很多，请问有哪些危害，注射了这些疫苗的家长怎么办？新闻只公布";
        cell.time.text = @"2016-03-25";
        cell.good.text = @"563";
        cell.comment.text = @"196";
       cell.love.text = @"320";
       return cell;
    }
    else  {
        IssueTableViewCell*cell = [myTableView dequeueReusableCellWithIdentifier:IssueReuseId ];
        if (!cell) {
            cell = (IssueTableViewCell *)[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier: IssueReuseId];
        }
        cell.name.text = @"不被理解的心情，好姐姐做到底吧，没几年就长大了！";
        cell.content.text = @"我也不想抱怨，可是真的有时候想想我们三姐弟怎么就有这样的父亲，真是够够的，父母赚钱不就是为了";
        cell.time.text = @"2016-03-25";
        cell.good.text = @"2663";
        cell.comment.text = @"1962";
        cell.love.text = @"";
        return cell;
    }
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
